﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using LogisticsBLL;
using System.Data;
using Model;

namespace WebLosgic.CapacityTruck
{
    public partial class CapacityTeam : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             rptBind();
            ddlbind();
            }
            
        }

        public void rptBind()
        {
            CarrierBLL car = new CarrierBLL();
            string table = "TruckTeam";
            string pramary = "TeamID";
            int pageindex = AspNetPagerTool.CurrentPageIndex;
            int pagesize = AspNetPagerTool.PageSize;
            int count = 0;
            string TeamName="0";
            string Leader = " ";
            DataTable read = car.rpttrucks(table,pramary,pageindex,pagesize, out count,TeamName,Leader);
            RptBindDrive.DataSource = read;
            AspNetPagerTool.RecordCount = count;
            RptBindDrive.DataBind();
        }

        public void ddlbind()
        {
            CarrierBLL car = new CarrierBLL();
            SqlDataReader read = car.rpttruck();
            ddlTeam.DataSource = read;
            ddlTeam.DataTextField = "TeamName";
            ddlTeam.DataValueField = "TeamName";
            ddlTeam.DataBind();
            ddlTeam.Items.Insert(0, new ListItem("请选择", "0"));
        }

        protected void Btnselect_Click(object sender, EventArgs e)
        {
            CarrierBLL car = new CarrierBLL();
            string table = "TruckTeam";
            string pramary = "TeamID";
            int pageindex = AspNetPagerTool.CurrentPageIndex;
            int pagesize = AspNetPagerTool.PageSize;
            string TeamName = ddlTeam.SelectedValue;
            string Leader = TxtTeamren.Text;
            int count = 0;
            DataTable read = car.rpttrucks(table, pramary, pageindex, pagesize,out count,TeamName,Leader);
            RptBindDrive.DataSource = read;
            AspNetPagerTool.RecordCount = count;
            RptBindDrive.DataBind();
        }

        protected void AspNetPagerTool_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }

        protected void Lbtn_Click(object sender, EventArgs e)
        {
            int TeamID = Convert.ToInt32((((LinkButton)sender).CommandArgument));
            Response.Redirect("CarrierTrucks.aspx?Tid="+TeamID);
        }
    }
}